//
//  APPConfig.swift
//  ezyform
//
//  Created by FengMoennig on 11/19/15.
//  Copyright © 2015 Client.Solution Pty Ltd. All rights reserved.
//

import UIKit
import RxSwift



// 测试 client.com.au.ezyform-Develop         GD-Beta
// 线上 client.com.au.GreenDeal               GreenDeal

// 2024052411
// 4.1.6


//只用于上传数据
let GlobalOperationQueue = OperationQueue()
class APPConfig: NSObject {
    static var isTestFlag: Bool {//true：当前是测试环境，false：是生产环境
        let appBundleID = Bundle.main.bundleIdentifier ?? ""
        if appBundleID.contains("Develop") {//开发证书
            return true
        }else{
            return false
        }
    }
    // product server address
    static var serverAddress : String {
        if isTestFlag{//development server address//ezyform-Develop
            return "https://staging.greendeal.com.au/"//For QA 新的测试环境，服务器在澳洲，和生产环境一样
        }else{//product server address
            return "https://www.greendeal.com.au/"
        }
    }
    //
    static var SentryDSN: String {
        if isTestFlag {
            return "http://b7487b7af9114f2092768037c1539537@sentry.client.com.au/14"
        }else{
            return "http://104a237be8e64709b95c757a463f2310@sentry.client.com.au/15"
        }
    }
    //false是用本地协议测试用；true表示使用api提供的协议
    static var OnlineStatementFlag: Bool = true
    static let ScanPanelColor: UIColor = UIColor(hexStr: "#54EE07")
    //扫描界面上边背景图的top，bottom,left right,及其size，用户计算scanViewTopMargin
    static let backgroundImageTopMargin: CGFloat = 40
    static let backgroundImageViewSize = CGSize(width: 343, height: 98)
    static let backgroundImageBottomMargin: CGFloat = 24
    static let backgroundImageLeftRightMargin: CGFloat = 16
    //一维码扫码区域设置
    static let scanViewTopMargin: CGFloat = (UIScreen.main.bounds.width - backgroundImageLeftRightMargin * 2) / backgroundImageViewSize.width * backgroundImageViewSize.height + backgroundImageTopMargin + backgroundImageBottomMargin
    static let scanViewHeight: CGFloat = 150
    static let scanViewHeightForAddManually: CGFloat = 150
    static var scanViewWidth: CGFloat {
        return APPConfig.WidthForPortrait
    }
    //二维码扫描区域设置
    static var qrScanViewWidth: CGFloat = ((UIScreen.main.bounds.width / 5 * 3) > 250 ? 250 : (UIScreen.main.bounds.width / 5 * 3))
    //所有缩略图size
    static var thumbnailSize: CGSize =  CGSize(width: 100, height: 100)
    static let SupportPhone: String = "0733871810"
    static let SupportEmail: String = "stc@greendeal.com.au"
    static let CallPhoneURL: String = "tel://"
    static let SendEmailURL: String = "mailto:"
    static let SendSMSURL: String = "sms://"
    static let DefaultVersionUpdateTitle: String = "The Latest Version"
    static let OldCachePasswordKey: String = "rememberPwd"
    static var CachePasswordKey : String {//新的Cache key
        let key = self.loginInfo.email + "-cachePwd"
        return key
    }
    static let LoginUserEmailKey: String = "LoginUserEmailKey"
    static let LoginUserTokenKey: String = "LoginUserTokenKey"
    static let LoginUserFullNameKey: String = "LoginUserFullNameKey"
    //头像的key
    class  var LoginUserAvatarKey: String {
        return self.loginInfo.email + "-Avatar"
    }
    class var ShowStartViewKey: String {
        return self.loginInfo.email + "-ShowStartView"
    }
    static var MagnifiedViewKey : String {//新的Cache key
        let key = self.loginInfo.email + "-MagnifiedViewFlag"
        return key
    }
    //
    static let ModelVCTopMargin: CGFloat = 20
    //new font for service feature
    static let ServiceFontNameOneBold: String = "PingFangSC-Semibold"
    static let ServiceFontNameTwoBold: String = "DIN-Bold"
    static let ServiceFontNameOne: String = "PingFangSC-Regular"
    static let ServiceFontNameTwo: String = "DIN-Regular"
    static let AlertDisplyInterval: Double = 3
    //开发和发布的license key，这种方式必须要联网校验license key的有效性才能扫描，APP没有使用
    static var  ScannerLicenseKey : String {
        if self.isTestFlag {//development server address//ezyform-Develop
            return "73f0acda"
        }else{//product server address
            return "7222820f"
        }
    }
    
    // 当前APP使用这个，这个是申请的离线的license，时效是一年九个月，后边这九个月是缓冲时效，这个license要放在后台，一年后修改为新的license，这个方式不用联网，
    //升级到9.0的临时license，因为不兼容8.*及以前的版本，所以两个key用分号分割，连接在一起
//    static var  ScannerLicense : String = "f0068NQAAAGbuhFaxQ5FxER/RBRir4icpyVRfBvZw2k2VmkqTz4wpxiGZZAN4v3lp2/qPhv6zhQGWhr1tI1sKkVu/PF9WaLs=;f0068NQAAAHE3+RuI1HnaUfWTuA8YXG1SCYj9oxfyjwqDM8TsZZPP5daKq3JMTA0y7aa0rprK9eI3xcLkwEvMy3ajEtAaves="
    static var  ScannerLicense : String = "f0068NQAAAGbuhFaxQ5FxER/RBRir4icpyVRfBvZw2k2VmkqTz4wpxiGZZAN4v3lp2/qPhv6zhQGWhr1tI1sKkVu/PF9WaLs=;f0068NQAAAJJBpnkl5wyvM2lftdrSMEs2j3mnPqFmInsxkW7R/m9kRTpcRAP8VY5dAqk9eQ0vvZLKN3fBeOEeJQnKWNJbLGY="
    static var ScannerLicenseValidFlag: Bool = false
    static var ScannerConfidence : Int = 50
    static var PanelNumberRegularExpression = "^[0-9a-zA-Z-:|]{5,}$"
    static var InverterNumberRegularExpression = "^[0-9a-zA-Z-:|]{5,}$"
    static var SignatureResendEmailToOwnerInterval: Int = 60 //秒
    static var SignatureResendSMSToOwnerInterval: Int = 60 //秒
    //MARK: - Fuzzy模式的设置
    static var ScannerDeblurLevel: Int = 9
    static var ScannerDeblurConfidence: Int = 40
    //MARK: - 需要自动开启反色条码扫描的panel brand,或model，二者有一个存在就自动开启
    static var ScannerPanelBrandOrModelForInvertedCode: String = ""
    //MARK: - 需要自动开启fuzzy code scanning扫描的panel brand,或model，二者有一个存在就自动开启
    static var ScannerPanelBrandOrModelForFuzzyCode: String = ""
    static var ConfirmEmailInterval: Int = 120 //秒
    static var VerificationCodeInterval: Int = 60 //秒，删除账号前，重新发送验证码的时间间隔
    //ShowErroInfo弹出信息中约定的强制更新前缀
    static let ShowErrorInfoUpgradePrefix: String = "ForceUpgrade:"
    
    //device type
    static let iPhoneType: String = "iPhone"
    static let iPadType: String = "iPad"
    
    // User Login Info
    static let loginInfo : LoginInfoModel = LoginInfoModel()
    class  var HeightForPortrait: CGFloat {
        var screemHeight: CGFloat = UIScreen.main.bounds.height
        
        if UIScreen.main.bounds.width > UIScreen.main.bounds.height {
            screemHeight = UIScreen.main.bounds.width
        }
        
        return screemHeight
    }
    class  var WidthForPortrait: CGFloat {
        var screemWidth: CGFloat = UIScreen.main.bounds.width
        
        if UIScreen.main.bounds.width > UIScreen.main.bounds.height {
            screemWidth = UIScreen.main.bounds.height
        }
        
        return screemWidth
    }
    class  var A4PaperSize: CGSize {
        return CGSize(width: 420 * 2, height: 594  * 2 )
    }
    // system color
    //
    // check list folder name
    static let CheckListFolderName: String = "CheckList"
    
    // check list folder name
    static let ServiceCheckListFolderName: String = "ServiceCheckList"
    // panel number dir name
    static let PanelNumberImagesDirName: String = "PanelNumbersImages"// panel number dir name
    static let InverterNumberImagesDirName: String = "InverterNumbersImages"
    
    // seperate flag
    static let ImageSuffix: String = ".png"
    static let PDFSuffix: String = ".pdf"
    
    static let SPVLearnMoreLink: String = "http://www.cleanenergyregulator.gov.au/RET/Scheme-participants-and-industry/Solar-Panel-Validation-initiative"
    class var documentsPath : NSString {
        let docDic : NSArray = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true) as NSArray
        return docDic.object(at: 0) as! NSString
    }
    //Setting data
    static var stateList: [String] = ["ACT","NSW","NT","QLD","SA","TAS","VIC","WA"]
    //Switch Checklist UI Key , 是否显示过Switch checklist ui的按钮
    static let currentLocation = LocationModel()
}
